
// 没明白这道题是串行的异步，还是并行，内容上他们可以并行
// 所以写了 1、then实现链式任务 和 2、Promise.all串行任务

//1、then实现链式任务
new Promise((resolve,reject)=>{
    setTimeout(function(){
        var a = "hello"
        resolve(a)
    },10)
}).then(a =>{
    return new Promise((resolve,reject)=>{
        setTimeout(function(){
            var b = "lagou"
            resolve(a+b)
        },10)
    })
}).then(result=>{
    setTimeout(() => {
        var c = "I ❤ U"
        console.log(result + c," then实现链式任务")
    }, 10);
})

// 2、Promise.all串行任务
var funA = new Promise((resolve,reject)=>{
    setTimeout(function(){
        var a = "hello"
        resolve(a)
    },10)
})
 
var funB = new Promise((resolve,reject)=>{
    setTimeout(function(){
        var b = "lagou"
        resolve(b)
    },10)
})
 
var funC = new Promise((resolve,reject)=>{
    setTimeout(function(){
        var c = "I ❤ U"
        resolve(c)
    },10)
})

Promise.all([funA,funB,funC]).then(result=>{
    console.log(result.join(" ")," Promise.all串行任务") 
})